const cloud = require('wx-server-sdk')
const Core = require('@alicloud/pop-core');

exports.main = async (event, context) => {
  console.log(event,111111)
  console.log(context,22222)
  var client = new Core({
    accessKeyId: 'LTAI5tKw5zBwPwBGDLG7k6oC',
    accessKeySecret: 'CXcki4MThr6t2XFHUVgv0jLcsDnyqu',
    endpoint: 'https://dysmsapi.aliyuncs.com',
    apiVersion: '2017-05-25'
  });

  console.log(2);

  var params = {
    "RegionId": "cn-hangzhou",
    "phoneNumbers": event.phone,
    "signName": "理型公园",
    "templateCode": "SMS_189620344",
    "templateParam": "{\"code\":\""+event.text+"\"}"
  }
  console.log(params);
  var requestOption = {
    method: 'POST',
    header: {
        "Content-Type": "application/json"
    },
  };
  return await client.request('SendSms', params, requestOption);
}